local lua_log = _G.lua_log
local LogDefine = require("common.LogDefine")

function init()
    if has_init then
        return
    end
    has_init = true
    --[[服务器测试输出--]] LOGID_TEST = lua_log.reg("log/test", "", 0)
    --[[服务器测试输出--]] LOGID_DEBUG = lua_log.reg("log/debug", "", 0)
    --[[服务器输出跟踪日志--]] LOGID_OSS_BT = lua_log.reg("log/err_bt", "", 0)
    --[[所有的pcall失败报错输出]] LOGID_ERR_PCALL = lua_log.reg("log/err_pcall", "", 0)
    --[[服务器obj数据统计--]] LOGID_MONITOR = lua_log.reg("log/monitor", "thread,luamem,scene,obj,monster,human,pet", 0)
    --[[GM指令--]] LOGID_OSS_GM_CODE = lua_log.reg("log/oss_gm_code", "uuid,account_name,role_name,cmd,arg", 0)
    --[[INNER_close]] LOGID_INNER_CLOSE = lua_log.reg("log/inner_close", "", 0)

    --[[客户端报错收集--]] LOGID_OSS_CLIENT_ERR = lua_log.reg("log/oss_client_err", "uuid,account_name,role_name,err", 300)
    --[[客户端资源加载报错收集--]] LOGID_OSS_CLIENT_LOAD_ERR = lua_log.reg("log/oss_client_load_err", "uuid,account_name,role_name,err", 300)

    --[[创建流失率--]] LOGID_OSS_CREATELOSS = lua_log.reg("log/oss_create_loss", "account_name,role_name,step,ip,pf,appid,appid2", 300)
    --[[注册]] LOGID_OSS_REGISTER = lua_log.reg("log/oss_register", "uuid,account_name,role_name,ip,pf,appid,cnt", 300)
    --[[登录--]] LOGID_OSS_LOGIN = lua_log.reg("log/oss_login", "uuid,account_name,role_name,level,ip", 300)
    --[[登出--]] LOGID_OSS_LOGOUT = lua_log.reg("log/oss_logout", "uuid,account_name,role_name,level,ip,reason,online_time", 300)
    --[[主指引完成--]] LOGID_OSS_GUIDE_MAIN = lua_log.reg("log/oss_guide_main", "uuid,account_name,role_name,level,ip,pf,appid,main_id,skip_type", 300)
    --[[子指引完成--]] LOGID_OSS_GUIDE_SUB = lua_log.reg("log/oss_guide_sub", "uuid,account_name,role_name,level,ip,pf,appid,sub_id", 300)

    --[[聊天--]] LOGID_OSS_CHAT = lua_log.reg("log/oss_chat", "uuid, account_name, role_name, ip, channel, content", 300)
    --[[升级--]] LOGID_OSS_LEVELUP = lua_log.reg("log/oss_level_up", "uuid,account_name,role_name,prev_level,level", 300)
    --[[守护之龙--]] LOGID_OSS_DRAGON_LEVEL = lua_log.reg("log/oss_dragon_lv", "uuid,account_name,role_name,level,skill_level", 300)
    --[[公会科技]] LOGID_OSS_UNION_TECH = lua_log.reg("log/oss_unionTech_lv", "uuid,account_name,role_name,type,level", 300)
    --[[金币流通--]] LOGID_OSS_JINBI = lua_log.reg("log/oss_money", "uuid,account_name,role_name,level,money,type,item_id,num,remain_money", 300)
    --[[钻石流通--]] LOGID_OSS_GOLD = lua_log.reg("log/oss_gold", "uuid,account_name,role_name,level,gold,type,item_id,num,remain_gold", 300)
    --[[友情值流通]] LOGID_OSS_FRIENDHEART = lua_log.reg("log/oss_friendheart", "uuid,account_name,role_name,level,friendheart,type,item_id,num,remain_friendheart", 300)
    --[[道具流通--]] LOGID_OSS_ITEM = lua_log.reg("log/oss_item", "uuid,account_name,role_name,level,type,item_id,num,afterCount", 300)
    --[[英雄流通--]] LOGID_OSS_HERO = lua_log.reg("log/oss_hero", "uuid,account_name,role_name,level,type,hero_id,num,hero_uuid, star", 300)
    --[[符文流通--]] LOGID_OSS_FUWEN = lua_log.reg("log/oss_fuwen", "uuid,account_name,role_name,level,type,fuwen_id,num", 300)
    --[[装备流通--]] LOGID_OSS_EQUIP = lua_log.reg("log/oss_equip", "uuid,account_name,role_name,level,type,equip_id,num, equip_uuid", 300)
    --[[召唤法阵--]] LOGID_OSS_DRAWCARD = lua_log.reg( "log/oss_drawcard", "uuid,account_name,role_name,level,type,hero_ids,item_id,num,zuanshi,jifen", 300)
    --[[战斗过程详细日志--]] LOGID_FIGHT_LOG = lua_log.reg("log/fight_log", "", 0)
    --[[充值--]] LOGID_OSS_PAY = lua_log.reg("log/oss_pay", "uuid, account_name,role_name,level, billno, buyID, money, gold, online,region", 300)
    --[[充值错误--]] LOGID_OSS_PAY_ERR =lua_log.reg("log/oss_pay_err", "account_name,result,billno, buyID, money, gold,region", 300)
    --[[腾讯购买--]] LOGID_OSS_TENCENT_BUY = lua_log.reg("log/oss_tencent_buy", "uuid,account_name,role_name,logintype,openid,openkey,pf,yuanbao,buyID", 300)

    --[[跨服相关调试日志--]] LOGID_MIDDLE_BT = lua_log.reg("log/err_middle_bt", "err", 0)

    --[[怪物死亡]] LOGID_OSS_MONSTER =lua_log.reg("log/oss_die", "uuid,account_name,role_name,level,kill_id,name,map_id", 300)
    --[[金币挑战]] LOGID_OSS_BATTLE_GOLD = lua_log.reg("log/oss_jbtz_lv", "uuid,account_name,role_name,lv", 300)
    --[[经验挑战]] LOGID_OSS_BATTLE_EXP = lua_log.reg("log/oss_exptz_lv", "uuid,account_name,role_name,lv", 300)
    --[[英雄挑战]] LOGID_OSS_BATTLE_HERO = lua_log.reg("log/oss_yxtz_lv", "uuid,account_name,role_name,lv", 300)
    --[[黄金龙穴]] LOGID_OSS_BATTLE_DRAGON = lua_log.reg("log/oss_hjlx_lv", "uuid,account_name,role_name,lv", 300)
    --[[水晶之地]] LOGID_OSS_BATTLE_CRYSTAL = lua_log.reg("log/oss_sjzd_lv", "uuid,account_name,role_name,lv", 300)
    --[[灵兽深渊]] LOGID_OSS_BATTLE_MOSHOU = lua_log.reg("log/oss_mssz_lv", "uuid,account_name,role_name,lv", 300)

    --[[主线关卡]] LOGID_OSS_BATTLE_MAINGATE = lua_log.reg("log/oss_maingate_lv", "uuid,account_name,role_name,lv", 300)
    --[[恶魔之塔]] LOGID_OSS_BATTLE_DEMONTOWER = lua_log.reg("log/oss_demonTower_lv", "uuid,account_name,role_name,lv", 300)
    --[[绝望深渊]] LOGID_OSS_BATTLE_DESPAIRABYSS = lua_log.reg("log/oss_despairAbyss_lv", "uuid,account_name,role_name,lv", 300)
    --[[遗迹探险]] LOGID_OSS_BATTLE_RELIC = lua_log.reg("log/oss_relic_lv", "uuid,account_name,role_name,lv", 300)

    --[[分享日志]] LOGID_OSS_SHARE = lua_log.reg("log/oss_share", "uuid, account_name, role_name, pf, appid, way", 300)
    --[[online 0：离线，保存db，未发货1：在线发货 2：离线期间请求，上线后发货发货--]] 
      LOGID_OSS_DELIVER = lua_log.reg("log/oss_deliver", "uuid, account_name,role_name,level, billno,money, type, itemId,cnt, online,region",300)
    --[[英雄起源活动领取日志]] LOGID_OSS_PAYREWARD = lua_log.reg("log/oss_payreward", "uuid,account_name,role_name,week,type,gift_index", 300)
    --[[英雄升级日志]] LOGID_OSS_HEROLVUP = lua_log.reg("log/oss_herolvup", "uuid,account_name,role_name,rerouuid,oldlv,newlv", 300)
    --[[遗迹探险插入DB]] LOGID_OSS_YJTX_DB = lua_log.reg("log/oss_yjtx_db", "",0)
end
init()

write = lua_log.write

function writeItemLog(human, grid, count, logType, index)
    local logTypeID = LogDefine.DEFINE[logType] + LogDefine.TYPE["item"]
    write(
        LOGID_OSS_ITEM,
        human.db._id,
        human.db.account,
        human.db.name,
        human.db.lv,
        logTypeID,
        grid.id,
        count,
        index or 0
    )
end

function qqInfo(human)
    return human.vopenid or 0, 0, 0, human.phpChanelID or "", 0
end

function writeShareLog(human, shareType)
    --'1:微信好友分享,2:微信朋友圈,3:微博,4:QQ,5:QQ好友,6:其他'九零  一 起玩 www.9 01  7 5.com 
    write(LOGID_OSS_SHARE, human.db._id, human.db.account, human.db.name, human.pf, human.appid, shareType)
end
